<style>

    #qu_select{
        position: relative;
        top:4px;
    }
</style>
<div class="content">
    <div class="header">
        <h1 class="page-title">题目列表</h1>
    </div>
    <ul class="breadcrumb">

        <li class="active">List</li>
    </ul>

    <div class="container-fluid">
        <div class="row-fluid">

            <div class="btn-toolbar">
                <button class="btn btn-primary" onClick="location='<?php echo url('Admin/Index/topic_add'); ?>'"><i class="icon-plus"></i>添加题目</button>
                <div class="btn-group">
                    <select name="qu_id" id="qu_select">
                        <option value="">请选择要查看的问卷</option>
                        <?php foreach( $que_list as $key => $val ){ ?>
                        <option <?php if(isset($qu_id)){ if($val['qu_id']==$qu_id){ echo 'selected'; }}  ?> value="<?php echo $val['qu_id']; ?>"><?php echo $val['qu_title']; ?></option>
                        <?php } ?>
                    </select>
                </div>
            </div>
            <div class="well">
                <table class="table">
                    <thead>
                    <tr>
                        <th>题目id</th>
                        <th>题目标题</th>
                        <th>所属问卷</th>
                        <th>所属部份</th>
                        <th>题目类型</th>
                        <!--<th>题目分数</th>-->
                        <th>题目排序</th>
                        <th>添加时间</th>
                        <th>是否启用</th>
                        <th style="width: 26px;"></th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php foreach ( $topic_list as $key => $val ) { ?>
                    <tr>
                        <td><?php echo $val['top_id']; ?></td>
                        <td style="text-overflow:ellipsis;width:300px;"><?php echo $val['top_title']; ?></td>
                        <td><?php echo $val['qu_title']; ?></td>
                        <td><?php echo $val['top_section']; ?></td>
                        <td>
                            <?php
                            if( $val['top_type'] == 1 ){
                                echo '单选题';
                            } else if( $val['top_type'] == 2 ) {
                                echo '多选题';
                            } else if( $val['top_type'] == 3 ) {
                                echo '填空题';
                            } else if( $val['top_type'] == 4 ){
                                echo '量表题';
                            }else if( $val['top_type'] == 5 ){
                                echo '跳转题';
                            }
                            ?>
                        </td>
                        <td><?php echo $val['top_order']; ?></td>
                        <!--<td><?php echo $val['top_order']; ?></td>-->
                        <td ><?php echo date('Y-m-d',$val['top_addtime']); ?></td>
                        <td><?php echo $val['top_status'] == 1 ? '是':'否'  ; ?></td>
                        <td>
                            <a class="is_qu" href="<?php echo url('Admin/Index/topic_edit',array('top_id'=>$val['top_id'])); ?>"><i class="icon-pencil"></i></a>
                            <a href="<?php echo url('Admin/Index/topic_del',array('top_id'=>$val['top_id'])); ?>" role="button" ><i class="icon-remove"></i></a>
                        </td>
                    </tr>
                    <?php } ?>
                    </tbody>
                </table>
            </div>
            <div class="pagination">
                <ul>
                    <?php echo $topic_list->render(); ?>
                </ul>
            </div>
            <script>
                $(function (){
                    $('#qu_select').change(function (){
                        var qu_id = $(this).val()
                        sessionStorage.setItem('qu_id',qu_id)
                        location.href = "<?php echo url('Admin/Index/topic_list'); ?>?qu_id=" + qu_id
                    })
                    setTimeout(function (e){
                        $('.pagination li a').each(function (e){
                            $(this).attr('href',"<?php echo url('Admin/Index/topic_list'); ?>" + $(this).attr('href'));
                        })
                    },500)

                })
            </script>